//
//  YRJAdviceViewController.m
//  YanRenjie
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 yanrenjie. All rights reserved.
//

#import "YRJAdviceViewController.h"
#import "YRJTripHeader.h"

@interface YRJAdviceViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property(nonatomic, retain)UICollectionView *titleCollectionView;
@property(nonatomic, retain)UICollectionViewFlowLayout *titleFlowLayout;
@property(nonatomic, retain)UIScrollView *tableViewScrollView;
@property(nonatomic, retain)NSArray *nameArray;   // 包含的是滚动条标题的名字
@end

@implementation YRJAdviceViewController
- (void)dealloc {
    [_titleCollectionView release];
    [_titleFlowLayout release];
    [_tableViewScrollView release];
    [_nameArray release];
    
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleFlowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.titleFlowLayout.itemSize = CGSizeMake((75.0 / 375) * WIDTH, (30.0 / 667) * HEIGHT);
    self.titleFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.titleFlowLayout.minimumInteritemSpacing = 1;
    self.titleFlowLayout.minimumLineSpacing = 1;
    self.titleFlowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    self.titleCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, (75.0 / 375) * WIDTH * 11, (94.0 / 667) * HEIGHT) collectionViewLayout:self.titleFlowLayout];
    self.titleCollectionView.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:self.titleCollectionView];
    self.titleCollectionView.scrollEnabled = YES;
    [self.titleCollectionView registerClass:[YRJAdviceNewsCollectionViewCell class] forCellWithReuseIdentifier:@"titleScrollCellReuse"];
    self.titleCollectionView.dataSource = self;
    self.titleCollectionView.delegate = self;
    [_titleCollectionView release];
    [_titleFlowLayout release];
    
    self.nameArray = [NSArray arrayWithObjects:@"最新", @"亚洲",@"欧洲",@"北美洲",@"南美洲",@"大洋洲",@"非洲",@"专题锦囊",@"中国内地",nil];
    [self createData];
}

- (void)createData {
    
}

#pragma mark - collectionView 两个必须实现的协议方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.nameArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    YRJAdviceNewsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"titleScrollCellReuse" forIndexPath:indexPath];
    [cell.myButton setTitle:self.nameArray[indexPath.row] forState:UIControlStateNormal];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end
